package com.lhl.jwt.controller;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @className: com.lhl.security.jwt.controller.TaskController
 * @description: TODO 类描述
 * @author: king
 * @date: 2020-11-09
 **/
@Api(tags = "TaskController", produces = "")
@RestController
@RequestMapping("/tasks")
public class TaskController {
    @GetMapping("/getTasks")
    @ResponseBody
    public String listTasks(){
        return "任务列表";
    }

    @PostMapping
    @PreAuthorize("hasRole('ADMIN')")
    public String newTasks(){
        return "创建了一个新的任务";
    }

    @GetMapping("/getTasks2")
    @PreAuthorize("hasRole('USER')")
    public String newTasks2(){
        return "XXXXX";
    }

    @GetMapping("/getTasks3")
    @PreAuthorize("hasAuthority('sys:menu:list')")
    public String newTasks3(){
        return "test-ok";
    }

    @GetMapping("/getTasks5")
    @PreAuthorize("hasAuthority('sys:menu:add')")
    public String newTasks5(){
        return "test-ok5";
    }
}
